package org.example.hospital_registration_system.controller;

import org.example.hospital_registration_system.model.AppointmentRelation;
import org.example.hospital_registration_system.service.AppointmentRelationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDate;
import java.util.List;

@RequestMapping("/relation")
@RestController
public class AppointmentRelationController {
    @Autowired
    private AppointmentRelationService appointmentRelationService;

    @RequestMapping("/getAll")
    public List<AppointmentRelation> getAll(Integer userId){
        if(userId==null){
            return null;
        }
        return appointmentRelationService.selectByUserId(userId);
    }

    @RequestMapping("/getByStatus")
    public List<AppointmentRelation> getByStatus(Integer userId,Integer status){
        if(userId==null || status==null){
            return null;
        }
        return appointmentRelationService.selectByStatus(userId,status);
    }

    @RequestMapping("/getByData")
    public List<AppointmentRelation> selectByData(Integer userId, String appointmentDate){
        if(userId==null || appointmentDate==null){
            return null;
        }
        return appointmentRelationService.selectByData(userId, appointmentDate);
    }

    @RequestMapping("/insertData")
    public String insertData(AppointmentRelation appointmentRelation){
        return appointmentRelationService.insertData(appointmentRelation);
    }

    @RequestMapping("/deleteRelation")
    public String deleteRelation(Integer relationId){
        return appointmentRelationService.deleteRelation(relationId);
    }

}
